<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>协议详情页</title>
</head>

<body>

    <!-- <embed src="http://10.120.65.140:2240/api/webssh/?hostname=localhost&username=root&password=cGFzc3dk" id="iframe"
        name="iframe" height="70%" width="100%" scrolling="auto" frameborder="0" onload="changeFrameHeight()" /> -->

    <!-- <iframe src="http://10.120.65.140:2240/api/webssh/?hostname=localhost&username=root&password=cGFzc3dk" height="70%" -->

    <iframe src="http://10.120.65.140:2240/api/webssh/" height="70%" width="100%" id="iframe" name="iframe" id="iframe"
        width="100%" onload="changeFrameHeight()">
    </iframe>

    <button onclick="accept()">接受</button>

    <button onclick="reject()">拒绝</button>


    <script>
        function accept() {
            console.log('~~~~~~~~~~ accept!');
        }

        function changeFrameHeight() {
            console.log('123');
            var iframe = document.getElementById("iframe");

            iframe.height = document.documentElement.clientHeight * 0.7;

            function wssh_connect() {
                // iframe.contentWindow.wssh.connect("localhost", "22", "root", "cGFzc3dk");
                iframe.contentWindow.wssh.connect("localhost", "22", "root", "passwd");

                // iframe.contentWindow.postMessage('localhost|22|root|cGFzc3dk', '*');
                // iframe.contentWindow.postMessage('localhost|22|root|passwd', '*');

                iframe.height = document.documentElement.clientHeight * 0.8;
            }

            setTimeout(wssh_connect, 1000);

            // iframe.contentWindow.postMessage('我是父元素传给子元素的数据哦！', '*');
            // iframe.contentWindow.postMessage('我是父元素传给子元素的数据哦！', '*');
        }
        //onresize属性可以用来获取或设置当前窗口的resize事件的事件处理函数
        //onresize事件会在窗口或框架被调整大小时发生
        window.onresize = function () {
            changeFrameHeight();
        }
    </script>

</body>

</html>